#include "stdafx.h"

#include <Money.h>
#include <Bank.h>
#include <Sum.h>


namespace
{
	TEST( Bank, ReduceSum )
	{
		const SumSp sum( new Sum( Money::Dollar( 3 ), Money::Dollar( 4 ) ) );
		const Bank bank;
		const auto result( bank.Reduce( *sum, _T("USD") ) );
		EXPECT_EQ( *Money::Dollar( 7 ), *result );
	}

	TEST( Bank, ReduceMoney )
	{
		const Bank bank;
		const auto result( bank.Reduce( *Money::Dollar( 1 ), _T("USD") ) );
		EXPECT_EQ( *Money::Dollar( 1 ), *result );
	}

	TEST( Bank, ReduceMoneyDifferenctCurrency )
	{
		Bank bank;
		bank.AddRate( _T("CHF"), _T("USD"), 2 );
		const auto result( bank.Reduce( *Money::Franc( 2 ), _T("USD") ) );
		EXPECT_EQ( *Money::Dollar( 1 ), *result );
	}

	TEST( Bank, IdentityRate )
	{
		EXPECT_EQ( 1, Bank().FindRate( _T("USD"), _T("USD") ) );
	}

} // unnamed namespace
